home *** CD-ROM | disk | FTP | other *** search
/ The Netter Presenter: Ur…ion in Overactive Bladder / The Netter Presenter: Urinary System - Structure & Function in Overactive Bladder.iso / mac / UrinarySystem.app / Contents / Main.dxr / Internal_8_Add-Delete from List - Default View.ls < prev    next >
Encoding:
Text File  |  2005-01-18  |  9.4 KB  |  292 lines

  1. global gPFimportedData, gPFname, gCurrentList, gNoteData, glCurrentListData, gImageLibNum, gImageDescription, glSelectedLabels, glSelectedLines, glPFListNames, gAction, glListImageNames, glImageList, gRenameListName, gCurrentScreen, gNewList, gListObject, PFList, gremovefromlistnotlviewswitch
  2.  
  3. on DoAction
  4.   case gAction of
  5.     #CloseNotesWindow:
  6.       window("notes").moveToBack()
  7.       window("notes").close()
  8.       window("Notes").forget()
  9.       gAction = EMPTY
  10.     #CloseHelpWindow:
  11.       window("Help").moveToBack()
  12.       window("Help").close()
  13.       window("Help").forget()
  14.       gAction = EMPTY
  15.     #AddImageToList:
  16.       CreateImageDefinition()
  17.       CheckForValidImageData()
  18.       AddToList()
  19.       UpdatePersonalFileData()
  20.       WritePersonalFileNoDialog()
  21.     #AddUnEditedImageToList:
  22.       CreateBasicImageDefinition()
  23.       CheckForValidImageData()
  24.       UpdateListData(#add)
  25.       UpdatePersonalFileData()
  26.       WritePersonalFileNoDialog()
  27.     #RemoveFromList:
  28.       CreateImageDefinition()
  29.       CheckForValidImageData()
  30.       RemoveImageFromList()
  31.       UpdatePersonalFileData()
  32.       WritePersonalFileNoDialog()
  33.     #RemoveFromListView:
  34.       RemoveImagePositionFromList()
  35.       UpdatePersonalFileData()
  36.       WritePersonalFileNoDialog()
  37.     #LoadListData:
  38.       ReadListData()
  39.     #LoadListDataDisplay:
  40.       LoadAndDisplayThumbnails()
  41.       HideSelection()
  42.     #UpdateImageInList:
  43.       CreateImageDefinition()
  44.       CheckForValidImageData()
  45.       UpdateListData(#update)
  46.       UpdatePersonalFileData()
  47.       WritePersonalFileNoDialog()
  48.     #DeleteList:
  49.       DeleteAList()
  50.       ClearListVars()
  51.       EraseThumbnails()
  52.       WritePersonalFileNoDialog()
  53.     #RenameList:
  54.       setUpResponseDialog()
  55.       runResponseDialog()
  56.       RenameAList()
  57.       UpdatePersonalFileData()
  58.       WritePersonalFileNoDialog()
  59.     #AbortAction:
  60.       abort()
  61.   end case
  62. end
  63.  
  64. on AddToList
  65.   if gPFimportedData = EMPTY then
  66.     gPFimportedData = glPFListNames & RETURN & "~" & gCurrentList & RETURN & value(gListObject).plImageData & RETURN & "~"
  67.     glPFListNames = list(gCurrentList)
  68.     glListImageNames = list(value(gListObject).pCurrentImage)
  69.   end if
  70.   UpdateListData(#add)
  71. end
  72.  
  73. on UpdateListData Option
  74.   if Option = #add then
  75.     append(glCurrentListData, value(gListObject).plImageData)
  76.     append(PFList.plFoundImages, value(gListObject).pCurrentImage)
  77.     PFList.pImageListPosition = glCurrentListData.count
  78.     PFList.pCurrentImage = value(gListObject).pCurrentImage
  79.   else
  80.     deleteAt(glCurrentListData, PFList.pImageListPosition)
  81.     addAt(glCurrentListData, PFList.pImageListPosition, value(gListObject).plImageData)
  82.   end if
  83. end
  84.  
  85. on UpdatePersonalFileData
  86.   delete gPFimportedData.line[1]
  87.   put glPFListNames & RETURN before gPFimportedData
  88.   EraseListData()
  89.   delete gPFimportedData.line[gPFimportedData.line.count]
  90.   put RETURN & "~" & gCurrentList after gPFimportedData
  91.   repeat with plateNum = 1 to glCurrentListData.count
  92.     put RETURN & string(getAt(glCurrentListData, plateNum)) after gPFimportedData
  93.   end repeat
  94.   put RETURN & "~" after gPFimportedData
  95. end
  96.  
  97. on ReadListData
  98.   repeat with lineNum = 1 to gPFimportedData.line.count
  99.     if gPFimportedData.line[lineNum].char[1] = "~" then
  100.       lineContent = gPFimportedData.line[lineNum]
  101.       if lineContent.char[2..lineContent.char.count] = gCurrentList then
  102.         platecount = 0
  103.         repeat while gPFimportedData.line[lineNum + platecount + 1].char[1] <> "~"
  104.           if gPFimportedData.line[lineNum + platecount + 1] = "[:]" then
  105.             exit repeat
  106.           end if
  107.           platecount = platecount + 1
  108.         end repeat
  109.         value(gListObject).plFoundImages = []
  110.         glListImageNames = []
  111.         glCurrentListData = []
  112.         repeat with plateNum = lineNum + 1 to lineNum + platecount
  113.           plateData = value(gPFimportedData.line[plateNum])
  114.           if plateData = [:] then
  115.             exit repeat
  116.           end if
  117.           append(glCurrentListData, plateData)
  118.           append(glListImageNames, getPropAt(plateData, 1))
  119.         end repeat
  120.         repeat with nameNum = 1 to glListImageNames.count
  121.           imageName = getAt(glListImageNames, nameNum)
  122.           imageNumber = imageName.char[6..imageName.char.count]
  123.           if gCurrentScreen = "PFlist" then
  124.             if getOne(glImageList, imageNumber) <> 0 then
  125.               append(value(gListObject).plFoundImages, imageNumber)
  126.             end if
  127.           end if
  128.         end repeat
  129.       end if
  130.     end if
  131.   end repeat
  132. end
  133.  
  134. on EraseListData
  135.   repeat with lineNum = 1 to gPFimportedData.line.count
  136.     if gPFimportedData.line[lineNum].char[1] = "~" then
  137.       lineContent = gPFimportedData.line[lineNum]
  138.       if lineContent.char[2..lineContent.char.count] = gCurrentList then
  139.         platecount = 0
  140.         repeat while gPFimportedData.line[lineNum + platecount + 1].char[1] <> "~"
  141.           if gPFimportedData.line[lineNum + platecount + 1] = "[:]" then
  142.             exit repeat
  143.           end if
  144.           platecount = platecount + 1
  145.         end repeat
  146.         repeat with oldPlateNum = lineNum + platecount down to lineNum
  147.           delete line oldPlateNum of gPFimportedData
  148.         end repeat
  149.       end if
  150.     end if
  151.   end repeat
  152. end
  153.  
  154. on ClearListVars
  155.   glCurrentListData = []
  156.   gCurrentList = EMPTY
  157.   value(gListObject).pCurrentImage = EMPTY
  158.   value(gListObject).plFoundImages = []
  159.   value(gListObject).plFoundImages = []
  160.   value(gListObject).pltnnumberlist = []
  161.   gllistimages = []
  162.   glListImageNames = []
  163. end
  164.  
  165. on RemoveImageFromList
  166.   if getPos(glCurrentListData, value(gListObject).plImageData) > 0 then
  167.     if gListObject = "PFList" then
  168.       PFList.pImageListPosition = value(gListObject).pImageListPosition
  169.     else
  170.       PFList.pImageListPosition = getPos(glCurrentListData, value(gListObject).plImageData)
  171.     end if
  172.     deleteAt(glCurrentListData, PFList.pImageListPosition)
  173.     PFList.plFoundImages = []
  174.     repeat with x = 1 to glCurrentListData.count
  175.       append(PFList.plFoundImages, getAt(getAt(getAt(glCurrentListData, x), 1), 1))
  176.     end repeat
  177.     if PFList.pImageListPosition > 1 then
  178.       PFList.pImageListPosition = PFList.pImageListPosition - 1
  179.       value(gListObject).plImageData = getAt(glCurrentListData, PFList.pImageListPosition)
  180.       if gremovefromlistnotlviewswitch then
  181.         exit
  182.       end if
  183.       LoadImageDefinition()
  184.       RestoreImage()
  185.     else
  186.       PFList.pImageListPosition = 0
  187.       if gremovefromlistnotlviewswitch then
  188.         exit
  189.       end if
  190.       ClearImageDefinition()
  191.       LoadImage(EMPTY)
  192.     end if
  193.   else
  194.     alert("This image has either been altered or has not been saved to the current list.")
  195.     abort()
  196.   end if
  197. end
  198.  
  199. on RemoveImagePositionFromList
  200.   deleteAt(glCurrentListData, PFList.pImageListPosition)
  201.   deleteAt(PFList.plFoundImages, PFList.pImageListPosition)
  202.   if PFList.pImageListPosition > 1 then
  203.     PFList.pImageListPosition = PFList.pImageListPosition - 1
  204.   else
  205.     PFList.pImageListPosition = 1
  206.   end if
  207.   if glCurrentListData <> [] then
  208.     PFList.plImageData = getAt(glCurrentListData, PFList.pImageListPosition)
  209.     LoadImageDefinition()
  210.   end if
  211.   value(gListObject).plImageData = [:]
  212.   gImageDescription = EMPTY
  213.   value(gListObject).pCurrentImage = EMPTY
  214.   value(gListObject).pCurrentImageTitle = EMPTY
  215.   value(gListObject).pSelectedImageSpriteNum = 0
  216.   member("status").text = EMPTY
  217.   member("description").text = EMPTY
  218.   HideSelection()
  219.   DisplayThumbsAfterDeletion()
  220. end
  221.  
  222. on DeleteAList
  223.   deleteOne(glPFListNames, gCurrentList)
  224.   delete gPFimportedData.line[1]
  225.   put glPFListNames & RETURN before gPFimportedData
  226.   repeat with lineNum = 1 to gPFimportedData.line.count
  227.     if gPFimportedData.line[lineNum].char[1] = "~" then
  228.       lineContent = gPFimportedData.line[lineNum]
  229.       if lineContent.char[2..lineContent.char.count] = gCurrentList then
  230.         platecount = 0
  231.         repeat while gPFimportedData.line[lineNum + platecount + 1].char[1] <> "~"
  232.           if gPFimportedData.line[lineNum + platecount + 1] = "[:]" then
  233.             exit repeat
  234.           end if
  235.           platecount = platecount + 1
  236.         end repeat
  237.         repeat with oldPlateNum = lineNum + platecount down to lineNum
  238.           delete line oldPlateNum of gPFimportedData
  239.         end repeat
  240.       end if
  241.     end if
  242.   end repeat
  243.   if glPFListNames.count = 0 then
  244.     append(glPFListNames, "list1")
  245.     gCurrentList = "list1"
  246.     gPFimportedData = "[" & QUOTE & "list1" & QUOTE & "]" & RETURN & "~list1" & RETURN & "~"
  247.     value(gListObject).plImageData = [:]
  248.     glCurrentListData = []
  249.     value(gListObject).pCurrentImage = EMPTY
  250.   end if
  251. end
  252.  
  253. on RenameAList
  254.   deleteOne(glPFListNames, gCurrentList)
  255.   append(glPFListNames, gRenameListName)
  256.   repeat with lineNum = 1 to gPFimportedData.line.count
  257.     if gPFimportedData.line[lineNum].char[1] = "~" then
  258.       lineContent = gPFimportedData.line[lineNum]
  259.       if lineContent.char[2..lineContent.char.count] = gCurrentList then
  260.         put "~" & gRenameListName into line lineNum of gPFimportedData
  261.       end if
  262.     end if
  263.   end repeat
  264.   gCurrentList = gRenameListName
  265. end
  266.  
  267. on AddAlist
  268.   if getOne(glPFListNames, gNewList) = 0 then
  269.     append(glPFListNames, gNewList)
  270.     delete gPFimportedData.line[1]
  271.     put glPFListNames & RETURN before gPFimportedData
  272.     put gNewList & RETURN & "~" after gPFimportedData
  273.   else
  274.     alert("That name is already in use.  Please select another.")
  275.     abort()
  276.   end if
  277. end
  278.  
  279. on LoadAndDisplayThumbnails
  280.   if not (gPFimportedData = EMPTY) then
  281.     ReadListData()
  282.   end if
  283.   DisplayThumbNails()
  284.   UpdateImageScroller()
  285. end
  286.  
  287. on DisplayThumbsAfterDeletion
  288.   PFList.pImageScroll = 1
  289.   DisplayThumbNails()
  290.   UpdateImageScroller()
  291. end
  292.